using Auth.Application.DTO.Input;
using Auth.Application.DTO.Output;
using Auth.Domain.Entities;
using AutoMapper;

namespace Auth.Application
{
    /// <summary>
    /// AutoMapper配置
    /// </summary>
    public class AutoMapping : Profile
    {
        public AutoMapping()
        {
            // User -> UserOutput
            CreateMap<UserModel, UserOutput>();

            // RegisterInput -> UserModel
            CreateMap<RegisterInput, UserModel>()
                .ForMember(dest => dest.Password, opt => opt.Ignore())
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.CreatedAt, opt => opt.Ignore())
                .ForMember(dest => dest.CreatedBy, opt => opt.Ignore())
                .ForMember(dest => dest.UpdatedAt, opt => opt.Ignore())
                .ForMember(dest => dest.UpdatedBy, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.Ignore())
                .ForMember(dest => dest.LastLoginTime, opt => opt.Ignore())
                .ForMember(dest => dest.IsActive, opt => opt.Ignore());

            // User -> LoginOutput
            CreateMap<UserModel, LoginOutput>();

            CreateMap<UserModel, ShowUserDTO>().ForMember(x => x.id, y => y.MapFrom(s => s.Id)).ForMember(x => x.name, y => y.MapFrom(s => s.RealName)).ForMember(x => x.description, y => y.MapFrom(s => s.RealName)).ForMember(x => x.UserId, y => y.MapFrom(s => s.Id));
        }
    }
} 